package logic

import (
	"context"
	"wxapi/internal/services"

	"wxapi/internal/svc"
	"wxapi/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type IndexActivityLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewIndexActivityLogic(ctx context.Context, svcCtx *svc.ServiceContext) *IndexActivityLogic {
	return &IndexActivityLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *IndexActivityLogic) IndexActivity() (resp *types.IndexActivity, err error) {
	activity, err := services.GetIndexActivity(l.ctx, l.svcCtx)
	if err != nil {
		return nil, err
	}
	if activity.ID == 0 {
		resp = &types.IndexActivity{
			ID:     0,
			Name:   "",
			Avatar: "",
		}
	} else {
		resp = &types.IndexActivity{
			ID:     activity.ID,
			Name:   activity.ActivityName,
			Avatar: activity.ActivityAvatar,
		}
	}

	return
}
